package com.mygdx.game_objects;

import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.math.Vector2;

public class Basket {

	private int width, height;
	private Rectangle basketShape;
	private Vector2 position;
	private Vector2 velocity;
	private static final float slideSpeed = 300;
	private int gameWidth;
	
	public Basket(float x, float y, int width, int height, int gameWidth) {
		position = new Vector2(x, y);
		velocity = new Vector2(0, 0);
		this.width = width;
		this.height = height;
		basketShape = new Rectangle();
		this.gameWidth = gameWidth;
	}
	
	public void update (float delta) {
		position.add(velocity.cpy().scl(delta));
		basketShape.set(position.x, position.y + 10, width, height - 10); //position.y + 10 and height - 10 to fit with the basket.
		if(position.x < 0) {
			position.x = 0;
		} else if(position.x + width > gameWidth) {
			position.x = gameWidth - width;
		}
	}
	
	public void slideLeft() {
		velocity.x = -slideSpeed;		

	}
	
	public void slideRight() {
		velocity.x = slideSpeed;

	}
	
	public void stop() {
		velocity.x = 0;
	}
	
	public float getX() {
		return position.x;
	}
	
	public float getY() {
		return position.y;
	}

	public int getWidth() {
		return width;
	}

	public int getHeight() {
		return height;
	}

	public Rectangle getBasketShape() {
		return basketShape;
	}
	
	public float getTailX() {
		return getX() + width;
	}
	
}
